import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/pages/user/Home.vue";
import Manage from "../views/pages/Manage.vue";
Vue.use(VueRouter);

// 路由配置
const routes = [
  // 登录路由
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/pages/user/Login.vue"),
  },
  // 主布局路由
  { 
    path: "/",
    name: "Manage",
    component: Manage,
    redirect: "/home",
    children: [
      // 首页
      { 
        path: "home", 
        name: "Home", 
        component: Home, 
        meta: { 
          nameKey: "navigation.home", 
          path: "/home",
          title: "首页"
        } 
      },

      // ===== 个人中心 =====
      { 
        path: "userInfo", 
        name: "UserInfo", 
        component: () => import("@/views/pages/user/UserInfo.vue"), 
        meta: { 
          nameKey: "navigation.userInfo", 
          path: "/userInfo",
          title: "个人信息"
        } 
      },

      // ===== 系统管理 =====
      { 
        path: "user", 
        name: "UserManage", 
        component: () => import("@/views/pages/system/User.vue"), 
        meta: { 
          nameKey: "navigation.user", 
          path: "/userManage",
          title: "用户管理"
        } 
      },
      { 
        path: "right", 
        name: "RightManage", 
        component: () => import("@/views/pages/system/Right.vue"), 
        meta: { 
          nameKey: "navigation.right", 
          path: "/rightManage",
          title: "权限管理"
        } 
      },
      { 
        path: "role", 
        name: "RoleManage", 
        component: () => import("@/views/pages/system/Role.vue"), 
        meta: { 
          nameKey: "navigation.role", 
          path: "/roleManage",
          title: "角色管理"
        } 
      },
      { 
        path: "systemConfig", 
        name: "SystemConfig", 
        component: () => import("@/views/pages/system/Config.vue"), 
        meta: { 
          nameKey: "navigation.systemConfig", 
          path: "/systemConfig",
          title: "系统配置"
        } 
      },

      // ===== 请假管理 =====
      { 
        path: "admin", 
        name: "LeaveAdmin", 
        component: () => import("@/views/pages/leave/Admin.vue"), 
        meta: { 
          nameKey: "navigation.leaveAdmin", 
          path: "/admin",
          title: "请假审批"
        } 
      },
      { 
        path: "student", 
        name: "LeaveStudent", 
        component: () => import("@/views/pages/leave/Student.vue"), 
        meta: { 
          nameKey: "navigation.leaveStudent", 
          path: "/student",
          title: "请假申请"
        } 
      },
      { 
        path: "adminHistory", 
        name: "LeaveAdminHistory", 
        component: () => import("@/views/pages/leave/AdminHistory.vue"), 
        meta: { 
          nameKey: "navigation.leaveAdminHistory", 
          path: "/adminHistory",
          title: "审批历史"
        } 
      },
      { 
        path: "studentHistory", 
        name: "LeaveStudentHistory", 
        component: () => import("@/views/pages/leave/StudentHistory.vue"), 
        meta: { 
          nameKey: "navigation.leaveStudentHistory", 
          path: "/studentHistory",
          title: "请假历史"
        } 
      },

      // ===== 考勤管理 =====
      // 考勤视图
      { 
        path: "adminAttendance", 
        name: "AdminAttendance", 
        component: () => import("@/views/pages/attendance/AdminAttendanceView.vue"), 
        meta: { 
          nameKey: "navigation.adminAttendance", 
          path: "/adminAttendance",
          title: "管理员考勤视图"
        } 
      },
      { 
        path: "teacherAttendance", 
        name: "TeacherAttendance", 
        component: () => import("@/views/pages/attendance/TeacherAttendanceView.vue"), 
        meta: { 
          nameKey: "navigation.teacherAttendance", 
          path: "/teacherAttendance",
          title: "教师考勤视图"
        } 
      },
      // 考勤功能
      { 
        path: "attendanceCheckIn", 
        name: "AttendanceCheckIn", 
        component: () => import("@/views/pages/attendance/AttendanceCheckIn.vue"), 
        meta: { 
          nameKey: "navigation.attendanceCheckIn", 
          path: "/attendanceCheckIn",
          title: "考勤签到"
        } 
      },
      { 
        path: "attendanceRecords", 
        name: "AttendanceRecords", 
        component: () => import("@/views/pages/attendance/AttendanceRecords.vue"), 
        meta: { 
          nameKey: "navigation.attendanceRecords", 
          path: "/attendanceRecords",
          title: "考勤记录"
        } 
      },
      { 
        path: "attendanceStats", 
        name: "AttendanceStats", 
        component: () => import("@/views/pages/attendance/AttendanceStats.vue"), 
        meta: { 
          nameKey: "navigation.attendanceStats", 
          path: "/attendanceStats",
          title: "考勤统计"
        } 
      },
      // 考勤配置
      { 
        path: "attendanceBatch", 
        name: "AttendanceBatch", 
        component: () => import("@/views/pages/attendance/AttendanceBatch.vue"), 
        meta: { 
          nameKey: "navigation.attendanceBatch", 
          path: "/attendanceBatch",
          title: "考勤批次"
        } 
      },
      { 
        path: "attendanceConfig", 
        name: "AttendanceConfig", 
        component: () => import("@/views/pages/attendance/AttendanceConfig.vue"), 
        meta: { 
          nameKey: "navigation.attendanceConfig", 
          path: "/attendanceConfig",
          title: "考勤配置"
        } 
      },
      { 
        path: "attendanceRules", 
        name: "AttendanceRules", 
        component: () => import("@/views/pages/attendance/AttendanceRules.vue"), 
        meta: { 
          nameKey: "navigation.attendanceRules", 
          path: "/attendanceRules",
          title: "考勤规则"
        } 
      },
      { 
        path: "teacherAttendanceManage", 
        name: "TeacherAttendanceManage", 
        component: () => import("@/views/pages/attendance/TeacherAttendanceManage.vue"), 
        meta: { 
          nameKey: "navigation.teacherAttendanceManage", 
          path: "/teacherAttendanceManage",
          title: "教师考勤管理"
        } 
      },

      // ===== 课程管理 =====
      { 
        path: "course", 
        name: "CourseManage", 
        component: () => import("@/views/pages/course/Course.vue"), 
        meta: { 
          nameKey: "navigation.course", 
          path: "/courseManage",
          title: "课程管理"
        } 
      },
      { 
        path: "selectedCourse", 
        name: "SelectedCourse", 
        component: () => import("@/views/pages/course/SelectedCourse.vue"), 
        meta: { 
          nameKey: "navigation.selectedCourse", 
          path: "/selectedCourse",
          title: "选课管理"
        } 
      },
      { 
        path: "studentCourses", 
        name: "StudentCourses", 
        component: () => import("@/views/pages/course/StudentCourses.vue"), 
        meta: { 
          nameKey: "navigation.studentCourses", 
          path: "/studentCourses",
          title: "学生课程"
        } 
      },
      { 
        path: "teacherCourses", 
        name: "TeacherCourses", 
        component: () => import("@/views/pages/course/TeacherCourses.vue"), 
        meta: { 
          nameKey: "navigation.teacherCourses", 
          path: "/teacherCourses",
          title: "教师课程"
        } 
      },

      // ===== 班级管理 =====
      { 
        path: "group", 
        name: "GroupManage", 
        component: () => import("@/views/pages/group/Group.vue"), 
        meta: { 
          nameKey: "navigation.group", 
          path: "/groupManage",
          title: "班级管理"
        } 
      },
    ]
  },
];

const router = new VueRouter({
  mode: "history", // 去除#号键
  routes,
});

export default router;
